//-----------------------------------------------------------------------------
// Name: DeadCow.cpp
// Auth: Paul Godfrey
// Desc: Moves a DeadCow around in 2D
//-----------------------------------------------------------------------------

#include "DeadCow.h"

#include "SharedConstants.h"

#include "corona/corona.h"

#include <GL/glut.h>
#include <math.h>

//-----------------------------------------------------------------------------
// Globals:
//-----------------------------------------------------------------------------
cDeadCow gDeadCow;


//-----------------------------------------------------------------------------
// Functions:
//-----------------------------------------------------------------------------
cDeadCow* GetDeadCow()
{
	return &gDeadCow;
}

//-----------------------------------------------------------------------------
// class cDeadCow:
//-----------------------------------------------------------------------------
cDeadCow::cDeadCow() :
	mXPosition(510.0f),
	mZPosition(510.0f)
{

}

cDeadCow::~cDeadCow()
{
}

//Moves dead cow to position
void cDeadCow::Move(float x, float z)
{
	mXPosition = x;
	mZPosition = z;
}

//Draw dead cow 
void cDeadCow::Draw()
{
	glPushMatrix();
	glTranslatef( mXPosition, 0.3f, mZPosition );

	glRotatef( 90.0f, 1.0f, 0.0f, 0.0f );

	glPushMatrix();
	glTranslatef(-1.25f, 0.0f, 0.35f);
	glColor3f(0.592f, 0.984f, 0.596f);
	
	//Start of Main Body
	glBegin(GL_QUADS);
	// flat top of DeadCow
	glColor3f(0.592f, 0.984f, 0.596f);
	glVertex3f(1.7f, 1.3f, -0.2f);
	glVertex3f(1.7f, 1.3f, -0.5f);
	glVertex3f(0.7f, 1.3f, -0.5f);
	glVertex3f(0.7f, 1.3f, -0.2f);

	//flat side1 panel1
	glColor3f(0.592f, 0.984f, 0.596f);
	glVertex3f(0.7f, 1.0f, 0.0f);
	glVertex3f(0.7f, 0.7f, 0.0f);
	glVertex3f(1.0f, 0.7f, 0.0f);
	glVertex3f(1.0f, 1.0f, 0.0f);
	
	//brown spot side1 panel2
	glColor3f(0.537f, 0.271f, 0.075f);
	glVertex3f(1.0f, 1.0f, 0.0f);
	glVertex3f(1.0f, 0.7f, 0.0f);
	glVertex3f(1.4f, 0.7f, 0.0f);
	glVertex3f(1.4f, 1.0f, 0.0f);
    
	//flat side1 panel3
	glColor3f(0.592f, 0.984f, 0.596f);
	glVertex3f(1.4f, 1.0f, 0.0f);
	glVertex3f(1.4f, 0.7f, 0.0f);
	glVertex3f(1.7f, 0.7f, 0.0f);
	glVertex3f(1.7f, 1.0f, 0.0f);

	//flat side2
	glVertex3f(1.7f, 1.0f, -0.7f);
	glVertex3f(1.7f, 0.7f, -0.7f);
	glVertex3f(0.7f, 0.7f, -0.7f);
	glVertex3f(0.7f, 1.0f, -0.7f);

	//diagonal top to side1
	glVertex3f(0.7f, 1.0f, 0.0f);
	glVertex3f(1.7f, 1.0f, 0.0f);
	glVertex3f(1.7f, 1.3f, -0.2f);
	glVertex3f(0.7f, 1.3f, -0.2f);

	//diagonal top to side1
	glVertex3f(0.7f, 1.3f, -0.5f);
	glVertex3f(1.7f, 1.3f, -0.5f);
	glVertex3f(1.7f, 1.0f, -0.7f);
	glVertex3f(0.7f, 1.0f, -0.7f);
	
	// flat bottom of DeadCow
	glVertex3f(0.7f, 0.5f, -0.2f);
	glVertex3f(0.7f, 0.5f, -0.5f);
	glVertex3f(1.7f, 0.5f, -0.5f);
	glVertex3f(1.7f, 0.5f, -0.2f);

	//diagonal side1 to bottom
	glVertex3f(0.7f, 0.7f, 0.0f);
	glVertex3f(0.7f, 0.5f, -0.2f);
	glVertex3f(1.7f, 0.5f, -0.2f);
	glVertex3f(1.7f, 0.7f, 0.0f);

	//diagonal side2 to bottom
	glVertex3f(1.7f, 0.7f, -0.7f);
	glVertex3f(1.7f, 0.5f, -0.5f);
	glVertex3f(0.7f, 0.5f, -0.5f);
	glVertex3f(0.7f, 0.7f, -0.7f);

	//backside
	glVertex3f(2.0f, 1.0f, -0.5f);
	glVertex3f(2.0f, 1.0f, -0.2f);
	glVertex3f(2.0f, 0.7f, -0.2f);
	glVertex3f(2.0f, 0.7f, -0.5f);

	//top diagonal to arse
	glVertex3f(1.7f, 1.3f, -0.5f);
	glVertex3f(1.7f, 1.3f, -0.2f);
	glVertex3f(2.0f, 1.0f, -0.2f);
	glVertex3f(2.0f, 1.0f, -0.5f);

	//bottom diagonal to arse
	glVertex3f(2.0f, 0.7f, -0.5f);
	glVertex3f(2.0f, 0.7f, -0.2f);
	glVertex3f(1.7f, 0.5f, -0.2f);
	glVertex3f(1.7f, 0.5f, -0.5f);

	//side1 diagonal to arse
	glVertex3f(1.7f, 1.0f, 0.0f);
	glVertex3f(1.7f, 0.7f, 0.0f);
	glVertex3f(2.0f, 0.7f, -0.2f);
	glVertex3f(2.0f, 1.0f, -0.2f);

	//side2 diagonal to arse
	glVertex3f(1.7f, 1.0f, -0.7f);
	glVertex3f(2.0f, 1.0f, -0.5f);
	glVertex3f(2.0f, 0.7f, -0.5f);
	glVertex3f(1.7f, 0.7f, -0.7f);
	
	//front
	glVertex3f(0.5f, 1.0f, -0.5f);
	glVertex3f(0.5f, 0.7f, -0.5f);
	glVertex3f(0.5f, 0.7f, -0.2f);
	glVertex3f(0.5f, 1.0f, -0.2f);

	//tail
	glColor3f(0.537f, 0.271f, 0.075f);
	glVertex3f(0.49f, 1.0f, -0.4f);
	glVertex3f(0.49f, 0.6f, -0.4f);
	glVertex3f(0.49f, 0.6f, -0.3f);
	glVertex3f(0.49f, 1.0f, -0.3f);
	
	//top diagonal to front
	glColor3f(0.592f, 0.984f, 0.596f);
	glVertex3f(0.5f, 1.0f, -0.5f);
	glVertex3f(0.5f, 1.0f, -0.2f);
	glVertex3f(0.7f, 1.3f, -0.2f);
	glVertex3f(0.7f, 1.3f, -0.5f);
	
	//bottom diagonal to front
	glVertex3f(0.7f, 0.5f, -0.5f);
	glVertex3f(0.7f, 0.5f, -0.2f);
	glVertex3f(0.5f, 0.7f, -0.2f);
	glVertex3f(0.5f, 0.7f, -0.5f);

	//side1 diagonal to front
	glVertex3f(0.5f, 1.0f, -0.2f);
	glVertex3f(0.5f, 0.7f, -0.2f);
	glVertex3f(0.7f, 0.7f, 0.0f);
	glVertex3f(0.7f, 1.0f, 0.0f);

	//side2 diagonal to front
	glVertex3f(0.7f, 1.0f, -0.7f);
	glVertex3f(0.7f, 0.7f, -0.7f);
	glVertex3f(0.5f, 0.7f, -0.5f);
	glVertex3f(0.5f, 1.0f, -0.5f);
	
	glEnd();

	glBegin(GL_TRIANGLES);

	//top rear triangle, side1
	glVertex3f(1.7f, 1.3f, -0.2f);
	glVertex3f(1.7f, 1.0f, 0.0f);
	glVertex3f(2.0f, 1.0f, -0.2f);

	//top rear triangle, side2
	glVertex3f(2.0f, 1.0f, -0.5f);
	glVertex3f(1.7f, 1.0f, -0.7f);
	glVertex3f(1.7f, 1.3f, -0.5f);

	//bottom rear triangle, side1
	glVertex3f(1.7f, 0.7f, 0.0f);
	glVertex3f(1.7f, 0.5f,-0.2f);
	glVertex3f(2.0f, 0.7f, -0.2f);

	//bottom rear triangle, side2
	glVertex3f(1.7f, 0.7f, -0.7f);
	glVertex3f(2.0f, 0.7f, -0.5f);
	glVertex3f(1.7f, 0.5f, -0.5f);

	//top front triangle, side1
	glVertex3f(0.7f, 1.3f, -0.2f);
	glVertex3f(0.5f, 1.0f, -0.2f);
	glVertex3f(0.7f, 1.0f, 0.0f);

	//top front triangle, side2
	glVertex3f(0.7f, 1.3f, -0.5f);
	glVertex3f(0.7f, 1.0f, -0.7f);
	glVertex3f(0.5f, 1.0f, -0.5f);

	//bottom front triangle, side1
	glVertex3f(0.7f, 0.7f, 0.0f);
	glVertex3f(0.5f, 0.7f, -0.2f);
	glVertex3f(0.7f, 0.5f, -0.2f);

	//bottom front triangle, side2
	glVertex3f(0.7f, 0.7f, -0.7f);
	glVertex3f(0.7f, 0.5f, -0.5f);
	glVertex3f(0.5f, 0.7f, -0.5f);

	glEnd();
	//End of Main Body

	//Legs start

	glBegin(GL_QUADS);
	//front leg on side 1
	//front leg side 1
	glVertex3f(0.7f, 0.7f, -0.1f);
	glVertex3f(0.7f, 0.0f, -0.1f);
	glVertex3f(0.8f, 0.0f, -0.1f);
	glVertex3f(0.8f, 0.7f, -0.1f);

	//front leg side 2
	glVertex3f(0.8f, 0.7f, -0.2f);
	glVertex3f(0.8f, 0.0f, -0.2f);
	glVertex3f(0.7f, 0.0f, -0.2f);
	glVertex3f(0.7f, 0.7f, -0.2f);
	
	//front leg front
	glVertex3f(0.7f, 0.7f, -0.2f);
	glVertex3f(0.7f, 0.0f, -0.2f);
	glVertex3f(0.7f, 0.0f, -0.1f);
	glVertex3f(0.7f, 0.7f, -0.1f);

	//front leg back
	glVertex3f(0.8f, 0.7f, -0.1f);
	glVertex3f(0.8f, 0.0f, -0.1f);
	glVertex3f(0.8f, 0.0f, -0.2f);
	glVertex3f(0.8f, 0.7f, -0.2f);
	
	//back leg on side 1
	//back leg side 1
	glVertex3f(1.6f, 0.7f, -0.1f);
	glVertex3f(1.6f, 0.0f, -0.1f);
	glVertex3f(1.7f, 0.0f, -0.1f);
	glVertex3f(1.7f, 0.7f, -0.1f);

	//back leg side 2
	glVertex3f(1.7f, 0.7f, -0.2f);
	glVertex3f(1.7f, 0.0f, -0.2f);
	glVertex3f(1.6f, 0.0f, -0.2f);
	glVertex3f(1.6f, 0.7f, -0.2f);
	
	//back leg front
	glVertex3f(1.6f, 0.7f, -0.2f);
	glVertex3f(1.6f, 0.0f, -0.2f);
	glVertex3f(1.6f, 0.0f, -0.1f);
	glVertex3f(1.6f, 0.7f, -0.1f);

	//back leg back
	glVertex3f(1.7f, 0.7f, -0.1f);
	glVertex3f(1.7f, 0.0f, -0.1f);
	glVertex3f(1.7f, 0.0f, -0.2f);
	glVertex3f(1.7f, 0.7f, -0.2f);
	
	//front leg on side 2
	//front leg side 1
	glVertex3f(0.7f, 0.7f, -0.5f);
	glVertex3f(0.7f, 0.0f, -0.5f);
	glVertex3f(0.8f, 0.0f, -0.5f);
	glVertex3f(0.8f, 0.7f, -0.5f);

	//front leg side 2
	glVertex3f(0.8f, 0.7f, -0.6f);
	glVertex3f(0.8f, 0.0f, -0.6f);
	glVertex3f(0.7f, 0.0f, -0.6f);
	glVertex3f(0.7f, 0.7f, -0.6f);
	
	//front leg front
	glVertex3f(0.7f, 0.7f, -0.6f);
	glVertex3f(0.7f, 0.0f, -0.6f);
	glVertex3f(0.7f, 0.0f, -0.5f);
	glVertex3f(0.7f, 0.7f, -0.5f);

	//front leg back
	glVertex3f(0.8f, 0.7f, -0.5f);
	glVertex3f(0.8f, 0.0f, -0.5f);
	glVertex3f(0.8f, 0.0f, -0.6f);
	glVertex3f(0.8f, 0.7f, -0.6f);
	
	//back leg on side 2
	//back leg side 1
	glVertex3f(1.6f, 0.7f, -0.5f);
	glVertex3f(1.6f, 0.0f, -0.5f);
	glVertex3f(1.7f, 0.0f, -0.5f);
	glVertex3f(1.7f, 0.7f, -0.5f);

	//back leg side 2
	glVertex3f(1.7f, 0.7f, -0.6f);
	glVertex3f(1.7f, 0.0f, -0.6f);
	glVertex3f(1.6f, 0.0f, -0.6f);
	glVertex3f(1.6f, 0.7f, -0.6f);
	
	//back leg front
	glVertex3f(1.6f, 0.7f, -0.6f);
	glVertex3f(1.6f, 0.0f, -0.6f);
	glVertex3f(1.6f, 0.0f, -0.5f);
	glVertex3f(1.6f, 0.7f, -0.5f);

	//back leg back
	glVertex3f(1.7f, 0.7f, -0.5f);
	glVertex3f(1.7f, 0.0f, -0.5f);
	glVertex3f(1.7f, 0.0f, -0.6f);
	glVertex3f(1.7f, 0.7f, -0.6f);

	glEnd();

	//End of Legs
	
	//HEAD start
	glBegin(GL_QUAD_STRIP);

	glVertex3f(2.2f, 1.1f, -0.4f);
	glVertex3f(2.0f, 1.1f, -0.4f);
	
	glVertex3f(2.2f, 1.1f, -0.3f);
	glVertex3f(2.0f, 1.1f, -0.3f);

	glVertex3f(2.2f, 1.0f, -0.2f);
	glVertex3f(2.0f, 1.0f, -0.2f);

	glVertex3f(2.2f, 0.9f, -0.2f);
	glVertex3f(2.0f, 0.9f, -0.2f);

	glVertex3f(2.2f, 0.6f, -0.3f);
	glVertex3f(2.0f, 0.6f, -0.3f);

	glVertex3f(2.2f, 0.6f, -0.4f);
	glVertex3f(2.0f, 0.6f, -0.4f);

	glVertex3f(2.2f, 0.9f, -0.5f);
	glVertex3f(2.0f, 0.9f, -0.5f);
	
	glVertex3f(2.2f, 1.0f, -0.5f);
	glVertex3f(2.0f, 1.0f, -0.5f);

	glVertex3f(2.2f, 1.1f, -0.4f);
	glVertex3f(2.0f, 1.1f, -0.4f);

	glEnd();

	glBegin(GL_QUADS);

	//back of head top
	glVertex3f(2.0f, 1.0f, -0.5f);
	glVertex3f(2.0f, 1.0f, -0.2f);
	glVertex3f(2.0f, 1.1f, -0.3f);
	glVertex3f(2.0f, 1.1f, -0.4f);
	
	//back of head bottom
	glVertex3f(2.0f, 0.6f, -0.4f);
	glVertex3f(2.0f, 0.6f, -0.3f);
	glVertex3f(2.0f, 0.9f, -0.2f);
	glVertex3f(2.0f, 0.9f, -0.5f);

	//front of head top
	glVertex3f(2.2f, 1.1f, -0.4f);
	glVertex3f(2.2f, 1.1f, -0.3f);
	glVertex3f(2.2f, 1.0f, -0.2f);
	glVertex3f(2.2f, 1.0f, -0.5f);

	//front middle of head
	glVertex3f(2.2f, 1.0f, -0.5f);
	glVertex3f(2.2f, 1.0f, -0.2f);
	glVertex3f(2.2f, 0.9f, -0.2f);
	glVertex3f(2.2f, 0.9f, -0.5f);

	//front of head bottom
	glVertex3f(2.2f, 0.9f, -0.5f);
	glVertex3f(2.2f, 0.9f, -0.2f);
	glVertex3f(2.2f, 0.6f, -0.3f);
	glVertex3f(2.2f, 0.6f, -0.4f);

	glEnd();

	//eyes
	glColor3f(0.0f, 0.0f, 0.0f);
	glPushMatrix();
	glTranslatef (2.2f, 0.9f, -0.25f);
	glutSolidSphere(0.035 , 5, 5);
	glPopMatrix();

	glPushMatrix();
	glTranslatef (2.2f, 0.9f, -0.45f);
	glutSolidSphere(0.035 , 5, 5);
	glPopMatrix();

	//nose
	glPushMatrix();
	glTranslatef (2.2f, 0.65f, -0.33f);
	glutSolidSphere(0.035 , 5, 5);
	glPopMatrix();

	glPushMatrix();
	glTranslatef (2.2f, 0.65f, -0.37f);
	glutSolidSphere(0.035 , 5, 5);
	glPopMatrix();

	glPopMatrix();
	//End of Head

	glPopMatrix();

}




